local skel = fk.CreateSkill {
  name = "charm_skill",
}

skel:addEffect("cardskill", {
  prompt = "#charm_skill",
  target_num = 1,
  max_turn_use_time = 1,
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card, extra_data)
    if player:prohibitUse(card) then return end
    return (extra_data and extra_data.bypass_times) or
      table.find(Fk:currentRoom().alive_players, function(p)
        return self:withinTimesLimit(player, Player.HistoryTurn, card, "charm", p)
      end)
  end,
  target_filter = function(self, player, to_select, selected, _, card, extra_data)
    if not Util.CardTargetFilter(self, player, to_select, selected, _, card, extra_data) then return end
    return self:modTargetFilter(player, to_select, selected, card, extra_data) and
      (
        #selected > 0 or
        (extra_data and extra_data.bypass_times) or
        self:withinTimesLimit(player, Player.HistoryTurn, card, "charm", to_select)
      )
  end,
  on_effect = function(self, room, effect)
    local to = effect.to
    local cardResponded = room:askToResponse(to, {
      pattern = "charm", cancelable = true, event_data = effect, skill_name = skel.name
    })
    if cardResponded then
      room:responseCard(cardResponded)
    else
      room:damage({
        from = effect.from,
        to = to,
        card = effect.card,
        damage = 1,
        damageType = fk.CharmDamage,
        skillName = self.name,
      })
    end
  end,
})

Fk:loadTranslationTable{
  ["charm_skill"] = "法",
  ["#charm_skill"] = "对一名角色造成1点法术伤害",
  ["charm_damage"] = "法术伤害",
}


return skel
